package com.atguigu03.field_method.method.exer;

/**
 * ClassName: MethodTest
 * Package: com.atguigu03.field_method.method.exer
 * Description:
 *
 * @Author xiao_qi
 * @Create 2024/3/16 22:34
 * @Version 1.0
 */
public class MethodTest {
    public static void main(String[] args) {

        person p1 = new person();
        p1.eat();

        p1.info();

        p1.sleep(8);

        String info = p1.hobby("编程");
        System.out.println(info);
    }
}

class person{
    String name;
    int age;
    char gender;

    public void eat(){
        System.out.println("人吃饭");

        sleep(8);

        System.out.println("name = " + name);
    }

    public void sleep(int hour){
        System.out.println("人至少每天睡眠" + hour + "小时");
    }

    public String hobby(String hobby){
        String info = "我的爱好是" + hobby;
        System.out.println(info);
//        return info;

        return "abc";
    }
    public void info(){
        System.out.println("Person info()");
    }
    public void printNumber(int targetNumber){ //10
        for(int i = 1;i <= targetNumber;i++){

            if(i == 4){
                return ; //用于结束方法。
                //return后面不能声明执行语句
//                System.out.println("迪丽热巴要约我吃饭");
            }

            System.out.println(i);
        }}}